package org.bot.plugin.web.source;

import org.bot.api.config.ClientConfig;
import org.bot.api.event.DataStorage;
import org.bot.api.source.SourceManage;
import org.bot.plugin.web.drive.LoadWeb;
import org.openqa.selenium.WebDriver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author 沧月
 * @create 0001 2023/10/1 21:32
 * @description <description class purpose>
 */

//@Component
public class SourceManageV2Impl implements SourceManage {

//    @Autowired
    LoadWeb loadWeb;

    @Override
    public void releaseAllSource(DataStorage data) {
        data.getSource(WebDriver.class).forEach(WebDriver::quit);
    }

    @Override
    public Object getSource() {
        return loadWeb.load(ClientConfig.getBotConfig());
    }

    @Override
    public void releaseSource(Object source) {
        ((WebDriver) source).quit();
    }
}
